<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>	
<script type="text/javascript" charset="UTF-8" src="${midContextPath}/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="${midContextPath}/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="${midContextPath}/css/smoothness.datepick.css"/>
<link rel="stylesheet" href="${midContextPath}/css/jquery.tooltip.css" />
<script src="${midContextPath}/js/jquery.tooltip.js" type="text/javascript"></script>
<script src="${midContextPath}/js/yaodian100.common.js" type="text/javascript"></script>
<script src="${midContextPath}/js/pageable.js" type="text/javascript" charset="UTF-8"></script>
	<script language="javascript">
	var i = 0;
	$().ready( function(){
		//init 主规格标签
		<c-rt:if test="${not empty product.mainCodeLabel}">
			<c-rt:choose>
				<c-rt:when test="${(fn:indexOf(product.mainCodeLabel,'颜色') == -1 and fn:indexOf(product.mainCodeLabel,'材质') ==-1)}">
					$("#defindMainLabel").show();
					$("#mainCodeLabel").val("${product.mainCodeLabel}");
					$("#mainCodeLabel1")[0].selectedIndex = 2;
				</c-rt:when>
				<c-rt:otherwise>
				$("#mainCodeLabel1").val("${product.mainCodeLabel}");
				</c-rt:otherwise>
			</c-rt:choose>
		</c-rt:if>
		//init 次规格标签
		<c-rt:if test="${not empty product.secondCodeLabel}">
			<c-rt:choose>
				<c-rt:when test="${(fn:indexOf(product.secondCodeLabel,'尺寸') == -1 and fn:indexOf(product.secondCodeLabel,'尺码') ==-1)}">
					$("#defindSecondLabel").show();
					$("#secondCodeLabel").val("${product.secondCodeLabel}");
					$("#secondCodeLabel1")[0].selectedIndex = 2;
				</c-rt:when>
				<c-rt:otherwise>
					$("#secondCodeLabel1").val("${product.secondCodeLabel}");
				</c-rt:otherwise>
			</c-rt:choose>
		</c-rt:if>		
		//主规格标签
		$("#mainCodeLabel1").change(function(){
			if ($(this).val() == "" ){
				$("#defindMainLabel").show();
			}else{
				$("#defindMainLabel").hide();
			}
			$("#mainCodeLabel").val("");
		});
		//次主规格标签
		$("#secondCodeLabel1").change(function(){
			if ($(this).val() == "" ){
				$("#defindSecondLabel").show();
			}else{
				$("#defindSecondLabel").hide();
			}
			$("#secondCodeLabel").val("");
		});		
		$("#saveProdSpecBtn").click(function(){
			if ( $("#mainCodeLabel1").val() != "" ){
 	 	 		$("#mainCodeLabel").val($("#mainCodeLabel1").val());
 	 	 	}
			if ( $("#secondCodeLabel1").val() != "" ){
 	 	 		$("#secondCodeLabel").val($("#secondCodeLabel1").val());
 	 	 	} 	 	 	
 	 	 	if ( $("#mainCodeLabel").val() == "" ){
 	 	 	 	alert("请输入自定义主规格标签");
 	 	 	 	return false;
 	 	 	}
 			if ( parseInt(wordCount($("#mainCodeLabel").val()),10) > 8){
				alert("主规格标签长度超出限制");
				return false; 	 			
 			}
 	 	 	if ( $("#secondCodeLabel").val() == "" ){
 	 	 	 	alert("请输入自定义次规格标签");
 	 	 	 	return false;
 	 	 	}
 			if ( parseInt(wordCount($("#secondCodeLabel").val()),10) > 8){
				alert("次规格标签长度超出限制");
				return false; 	 			
 			} 
 			<c-rt:if test="${(empty product.specifications or empty product.activateSpecMajors) and tempProdSpec ne 'Y'}">
 			if ( $("#editMainSpecName").val() == "" ){
 	 			alert("请输入主规格");
 	 			return false;
 			}
 			var mainSplit = $("#editMainSpecName").val().split(",");
 			for(var i = 0 ; i < mainSplit.length; i++ ){
 				if ( parseInt(wordCount(mainSplit[i]),10) > 16){
 					alert("每个主规格上限8个汉字");
 					return false; 	 			
 	 			}
 			}
 			if ( $("#editSecondSpecName").val() == "" ){
 	 			alert("请输入次规格");
 	 			return false;
 			}	 	 	
 			var secondSplit = $("#editSecondSpecName").val().split(",");
 			for(var i = 0 ; i < secondSplit.length; i++ ){
 				if ( parseInt(wordCount(secondSplit[i]),10) > 16){
 					alert("每个次规格上限8个汉字");
 					return false; 	 			
 	 			}
 			}
 			</c-rt:if>
 	 	 	$("#specForm").submit();
		});
		//删除主规格(新增)
		$("a[id*='mainDel_']").click(function(){
			deleteRow($(this));
		});			
		//删除次规格(新增)
		$("a[id*='secondDel_']").click(function(){
			var tempId = $(this).attr("id").split("_");
			var rowCount = 0;
			$("a[id*='secondDel_new_" + tempId[2] + "_']").each(function(){
				rowCount++;
			});
			deleteRow($(this));
			if ( 1 == rowCount ){
				deleteRow($("#mainDel_new_" + tempId[2]));
			}
		});		
		//删除主规格(修改)
		$("input[name='mainDel']").each(function(){
			$(this).click(function(){
				//将主规格底下的次规格全删除或全不删除
				var tempId = $(this).attr("id").split("_");
				var rowCount = 0;
				if ( $(this).attr("checked") == true){
					$("input[id*='secondDel_" + tempId[1] + "_']").each(function(){
						$(this).attr("checked","checked");
					});
				}else{
					$("input[id*='secondDel_" + tempId[1] + "_']").each(function(){
						$(this).attr("checked","");
					});
				}
			});
		});		
		
		//删除次规格(修改)
		$("input[name='secondDel']").each(function(){
			$(this).click(function(){
				//找出这个主规格共有几个次规格
				var tempId = $(this).attr("id").split("_");
				var rowCount = 0;
				$("input[id*='secondDel_" + tempId[1] + "_']").each(function(){
					rowCount++;
				});
				if ( 1 == rowCount ){
					if ( $(this).attr("checked") == true){
						$("#mainDel_" + tempId[1]).attr("checked","checked");
					}else{
						$("#mainDel_" + tempId[1]).attr("checked","");
					}
				}
			});
		});
		//新增主规格
		$("#major").click(function(){
			openDialogById('新增主规格',null, 350, 180,'majorDialog');
 	 	});
 	 	//全选/全不选次规格
 	 	$("#addSpecSelAll").click(function(){
			$(":input[id*=addSpec_]").attr('checked',$("#addSpecSelAll").attr('checked'));
		});
 	 	$("#addMajorBtn").click(function(){
 	 	 	if ( $("#mainSpecName").val() == "" ){
 	 	 		//return ydValidate("addOneMajor","请输入主规格");
 	 	 		alert("请输入主规格");
 	 	 		return false;
 	 	 	}
 	 	 	var specNames = "${product.mainSpecName}".split(",");
	 	 	var r = 0;
 	 	 	for(var i = 0 ; i < specNames.length; i++ ){
 	 	 	 	if ( $("#mainSpecName").val() == specNames[i] ){
 	 	 	 	 	r++;
 	 	 	 	}
 	 	 	}
 	 	 	if ( r > 0 ){
 	 	 		alert("主规格已存在，请勿新增重复的主规格");
	 	 	 	return false;
 	 	 	}
 	 	 	if ( parseInt(wordCount($("#mainSpecName").val()),10) > 16){
 	 	 		alert("主规格字元长度超出限制");
 	 	 		return false;
 	 		}
 	 	 	i = 0;
 	 	 	$(":input[type='checkbox'][name='addSpecSel']").each(function(){
 	 	 	 	if ($(this).attr("checked") == true ){
 	 	 	 	 	i++;
 	 	 	 	}
 	 	 	});
 	 	 	if ( i == 0 ){
 	 	 	 	//return ydValidate("selSpecMsg","请选择次规格");
 	 	 	 	alert("请选择次规格");
 	 	 	 	return false;
 	 	 	}
 	 	 	$("#addMajorForm").submit();
 	 		$("#majorDialog").dialog("close");
 	 	});
 	 	$("#cancelMajorBtn").click(function(){
 	 		$("#mainSpecName").val("");
 	 		$("#majorDialog").dialog("close");
 	 	});

	 	$("#secondSpecName1").change(function(){
		 	if ( $(this).val() != "" ){
			 	$("#define").hide();
		 	}else{
			 	$("#define").show();
			 	$("#secondSpecName").val("");
		 	}
	 	});
		//新增次规格
		$("#spec").click(function(){
			openDialogById('新增次规格',null, 350, 180,'specDialog');
 	 	});
 	 	//全选/全不选主规格
		$("#addMajorSelAll").click(function(){
			$(":input[id*=addMajor_]").attr('checked',$("#addMajorSelAll").attr('checked'));
		}); 	 	
 	 	$("#addSpecBtn").click(function(){
 	 	 	if ( $("#secondSpecName1").val() != "" ){
 	 	 		$("#secondSpecName").val($("#secondSpecName1").val());
 	 	 	}
 	 		if ( $("#secondSpecName").val() == "" ){
 	 	 		//return ydValidate("addOneMajor","请输入主规格");
 	 	 		alert("请输入次规格");
 	 	 		return false;
 	 	 	}
 	 	 	
 	 	 	if ( $("#secondSpecName1").val() == "" ){
 	 	 	 	var specNames = "${product.secondSpecName}".split(",");
 	 	 	 	var r = 0;
 	 	 	 	
 	 	 	 	for(var i = 0 ; i < specNames; i++ ){
 	 	 	 	 	if ( $("#secondSpecName").val() == specNames[i] ){
 	 	 	 	 	 	r++;
 	 	 	 	 	}
 	 	 	 	}
 	 	 	 	if ( r > 0 ){
 	 	 	 		alert("次规格已存在，请勿新增重复的次规格");
	 	 	 	 	return false;
 	 	 	 	}
 	 	 	}
 	 	 	if ( parseInt(wordCount($("#secondSpecName").val()),10) > 16){
 	 	 		alert("次规格字元长度超出限制");
 	 	 		return false;
 	 		}
 	 		i = 0;
 	 	 	$(":input[type='checkbox'][name='addMajorSel']").each(function(){
 	 	 	 	if ($(this).attr("checked") == true ){
 	 	 	 	 	i++;
 	 	 	 	}
 	 	 	});
 	 	 	if ( i == 0 ){
 	 	 	 	//return ydValidate("selSpecMsg","请选择次规格");
 	 	 	 	alert("请选择主规格");
 	 	 	 	return false;
 	 	 	}
 	 	 	$("#addSpecForm").submit();
 	 		$("#specDialog").dialog("close");
 	 	});
 	 	
 	 	$("#cancelSpecBtn").click(function(){
 	 		$("#secondSpecName").val("");
 	 		$("#specDialog").dialog("close");
 	 	}); 	 	

 	 	$("input[name*='submit']").click(function(){
 	 	 	if ( $(this).attr("name") == "submit1" || $(this).attr("name") == "submit2" ){
 				$("#saveFlag").val($(this).attr("id"));
				try {
					$("input[id*='spcMaxCountPerOrder_']").each(function(i,item){
						if(item.value == ""){
							alert("请输入订单,单笔最大可销售数");
							item.focus();
							throw item;
						}
						var tmpIdNum = item.id.replace("spcMaxCountPerOrder_","");
						if(parseInt(item.value)<parseInt($("input[id='spcMinCountPerOrder_"+tmpIdNum +"']").val(),10)){
							alert("单笔最大可销售数不可小於 单笔最小可销售数");
							item.focus();
							throw item;
						}
					});
					$("input[id*='spcMinCountPerOrder_']").each(function(i,item){
						if(item.value == ""){
							alert("请输入订单,单笔最小可销售数");
							item.focus();
							throw item;
						}
						if(parseInt(item.value)<=parseInt(0,10)){
							alert("单笔最小可销售数要大於0");
							item.focus();
							throw item;
						}
					});
				
					$("input[id*='spcSafeInventory_']").each(function(i,item){
						if(item.value == ""){
							alert("请输入安全库存量");
							item.focus();
							throw item;
						}
					});		
				}catch(e){
					return false;
				}
	 	 		$("#majorForm").submit();
 	 	 	}
 	 	});

		//$("tr[id*='tdDesc_']").tooltip();
		$('#arrivalDate').datepick({minDate: '+1D', showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-1:+1'});
	    	
		$("input[name='spcReverseInventory']").each(function(i,item){
			$(this).onlyInteger();
		});
		$("input[name='spcMaxCountPerOrder']").each(function(i,item){
			$(this).onlyInteger();
		});
		$("input[name='spcMinCountPerOrder']").each(function(i,item){
			$(this).onlyInteger();
		});
		$("input[name='spcSafeInventory']").each(function(i,item){
			$(this).onlyInteger();
		});
		$("#hotSaleInventory").onlyInteger();
		$("#maxCount").onlyInteger();
		$("#minCount").onlyInteger();
		$("#safeCount").onlyInteger();

		$("input[type=button]").each(function(){
			$(this).click(function(){
				if ( "maxCountBtn" == $(this).attr("id") ){
					if ( "" == $("#maxCount").val() || 0 == parseInt($("#maxCount").val(),10) ){
						alert("请输入单笔订单最大可售数/单笔订单最大可售数不可為0");
						$("#maxCount").focus();
						return false;
					}else{
						$("input[id*='spcMaxCountPerOrder_']").each(function(){
							$(this).val($("#maxCount").val());
						});
					}
				}
				if ( "minCountBtn" == $(this).attr("id") ){
					if ( "" == $("#minCount").val() || 0 == parseInt($("#minCount").val(),10) ){
						alert("请输入单笔订单最小可售数/单笔订单最小可售数不可為0");
						$("#minCount").focus();
						return false;
					}else{
						$("input[id*='spcMinCountPerOrder_']").each(function(){
							$(this).val($("#minCount").val());
						});
					}
				}
				if ( "safeCountBtn" == $(this).attr("id") ){
					if ( "" == $("#safeCount").val() || 0 == parseInt($("#safeCount").val(),10) ){
						alert("请输入安全库存量/安全库存量不可為0");
						$("#safeCount").focus();
						return false;
					}else{
						$("input[id*='spcSafeInventory_']").each(function(){
							$(this).val($("#safeCount").val());
						});
					}
				}
			});
		});

		/*上一步*/
		$("#previous").click(function(){
			location.href="${midContextPath}/product2/edit.do?productId=${productId}";
		});
	});
</script>			
<h1>商品管理 - 商品规格<br/>
	<div class="f-link">
		<a href="${midContextPath}/product2/list.do">回商品列表页</a>
	</div>
</h1>
<br/>
<!-- include product step menu -->
<jsp:include page="commonMenu2.jsp"/>
<s:actionerror escape="false"/>
<s:actionmessage />
<s:form action="saveProdSpec.do" method="post" id="specForm">
	<table class="tb-data" width="100%">
		<thead>
		 <tr>
				<th>商品名称<br/>（商品编号）</th>
				<td>${product.productName}(${productId})</td>
				<th>预计到货日</th>
				<td><fmt-rt:formatDate value="${product.arrivalDate}" pattern="yyyy-MM-dd" var="stockDate"/>
					<input type="text" name="arrivalDate" id="arrivalDate" size="10" maxlength="10" value="${stockDate}"/>
				</td>
		 </tr>
		 <tr>
		 		<th>热销数</th>
		 		<td><input type="text" maxlength="8" id="hotSaleInventory" size="5" value="${product.hotSaleInventory}" name="hotSaleInventory"/></td>
				<th>缺货登记数</th>
				<td>${stockQty}</td>
		 </tr>
		 <tr>
		 	<th><span class="txt-red">*</span>主规格名</th>
		 	<td>
		 		<s:select id="mainCodeLabel1" name="mainCodeLabel1" list="mainLabelMenu.options" listKey="value.name"  listValue="key"/>
		 		<div id="defindMainLabel" style="display:none"><input type="text" name="mainCodeLabel" id="mainCodeLabel" size="8" value=""/></div>
		 		<br/><span class="txt-gy">主规格名上限为4个汉 字，例如颜色、材质;也可以选择自定义主规格名</span>
		 	</td>
		 	<th><span class="txt-red">*</span>次规格名</th>
		 	<td>
		 		<s:select id="secondCodeLabel1" name="secondCodeLabel1" list="secondLabelMenu.options" listKey="value.name"  listValue="key"/>
		 		<div id="defindSecondLabel" style="display:none;"><input type="text" name="secondCodeLabel" id="secondCodeLabel" size="8" value=""/></div>
		 		<br/><span class="txt-gy">次规格名上限为4个汉 字，例如尺寸、尺码;也可以选择自定义次规格名</span>
		 	</td>
		 </tr>
		<c-rt:if test="${(empty product.specifications or empty product.activateSpecMajors) and tempProdSpec ne 'Y'}">
			<tr>
				<th>新增主/次规格</th>
				<td colspan="3">
					主规格：<input type="text" id="editMainSpecName" name="mainSpecName" size="50"/>
					次规格：<input type="text" id="editSecondSpecName" name="secondSpecName" size="50"/><br/>
					<span class="txt-gy">每个规格上限8个汉字，每个规格间用英文逗号分开；主次规格均为必填项;例如：主规格输入红色,蓝色；次规格输入S,M,L；<br/>点击新增后则显示为红色，蓝色主规格下各有次规格S,M,L。每次使用该功能新增后将会覆盖原先的规格。</span>
				</td>
			</tr>
		</c-rt:if>
		 <tr>
		 	<td colspan="4">
		 		<input type="hidden" name="addType" value=""/>
		 		<input type="button" id="saveProdSpecBtn" name="saveProdSpecBtn" value="确定"/>
		 		<span class="txt-gy">上述资料异动后请点击【确定】保存</span>
		 	</td>
		 </tr>
	</table>
</s:form>	
<br/><br/>
<s:actionerror escape="false"/>
<s:actionmessage />
<br/>
<c-rt:if test="${not empty product.specifications and not empty product.activateSpecMajors}">
<s:form action="spec.do" method="post">
	<div class="f-link">
		<b>主规格状态：</b>
	  <s:select name="specStatusParam" list="specStatusMenu.options" listKey="key"  listValue="value.name"/>
	  <input type="hidden" name="productId" value="${product.productId}"/>		
		<input type="button" value="查找" onclick="this.form.submit();" />
		<a href="javascript:void(0);" id="major">新增主规格</a>
		<a href="javascript:void(0);" id="spec">新增次规格</a>
	</div>
</s:form>
</c-rt:if>
<c-rt:if test="${not empty product.specifications or tempProdSpec eq 'Y'}">
<s:form action="saveMajor.do" method="post" id="majorForm">	
	<table class="tb-data" width="100%">
		<thead>
  		<tr>
		   	<th width="80px">主规格</th>
		   	<th width="40px"><span class="txt-red">*</span>排<br/>序</th>
		   	<th width="40px">停<br/>用</th>
		   	<td colspan="13">
			   	<table class="tb-data" width="100%">
				   	<tr>
					   	<th width="10%">次规格</th>
					   	<th>属性代码</th>
					   	<th width="10%">规格料号</th>
					   	<th width="10%">规格条码</th>
					   	<th width="8%">
					   		<span class="txt-red">*</span>单笔订单最大<br/>可售数<br/>
					   		<input type="text" name="maxCount" id="maxCount" size="3" maxlength="3"/><br/>
					   		<input type="button" name="maxCountBtn" id="maxCountBtn" value="套用"/>
					   	</th>
					    <th width="8%">
					    	<span class="txt-red">*</span>单笔订单最小<br/>可售数<br/>
					   		<input type="text" name="minCount" id="minCount" size="3" maxlength="3"/><br/>
					   		<input type="button" name="minCountBtn" id="minCountBtn" value="套用"/>
					    </th>
					    <th width="8%">
					    	<span class="txt-red">*</span>安全<br/>库存量<br/>
					    	<input type="text" name="safeCount" id="safeCount" size="3" maxlength="3"/><br/>
					   		<input type="button" name="safeCountBtn" id="safeCountBtn" value="套用"/>
					    </th>
					    <th width="8%">可售数</th>
							<th width="8%">已售数</th>
							<th width="8%">取消数</th>
							<th width="8%">排序</th>
							<th width="5%">停用</th>
							<th width="10%">销售库存<br/>查询</th>
				   	</tr>
			   	</table>
		   	</td>
	    </tr>
	  </thead>
		<tbody>
			<c-rt:if test="${not empty majors}">
				<c-rt:forEach items="${majors}" var="major" varStatus="index">
					<tr class="moveMajor" id="tdDesc_${index.count}" title="建立者:${major.createUser} 建立日期:${major.createDate}<br/>修改者:${major.modifyUser} 修改日期:${major.modifyDate}">
						<td width="80px">
							${major.mainSpecName}
							<input type="hidden" name="majorName" value="${major.mainSpecName}" />
							<input type="hidden" name="majorId" value="${major.mainSpecId}"/>
						</td>
						<td width="40px">
							<a href="javascript:void(0);" onClick="return moveRowUp($(this),'moveMajor');" href="#">↑上移</a><br/>
							<a href="javascript:void(0);" onClick="return moveRowDown($(this),'moveMajor');" href="#">↓下移</a>	
						</td>
						<td width="40px"><input name="mainDel" id="mainDel_${major.mainSpecId}" type="checkbox" value="${major.mainSpecId}" ${major.isDelete eq 'Y' ? "checked='checked'" : "" }/></td>
						<td colspan="13">
							<table class="tb-data" width="100%">
								<c-rt:forEach items="${product.specMap[major.mainSpecName]}" var="spec" varStatus="rows_index">
									<tr class="moveSpec" id="tdDesc_${index.count}_${rows_index.count}" title="建立者:${spec.createUser} 建立日期:${spec.createDate}<br/>修改者:${spec.modifyUser} 修改日期:${spec.modifyDate}">
										<td width="10%">
											${spec.secondSpecName}
											<input type="hidden" name="spcMajorName" value="${major}"/>
											<input type="hidden" name="spcId" value="${spec.specificationId}"/>
											<input type="hidden" name="spcName" value="${spec.secondSpecName}" />
										</td>
										<td>
										${pu:reqSet('specId', spec.specificationId)}
										<%
										String specId=String.valueOf(request.getAttribute("specId"));
										if(specId!=null){
										int specIdLength=specId.length();
										for(int i=0;i<(10-specIdLength);i++){
											specId="0"+specId;
										}
										}
										request.setAttribute("specId", specId);
										%>
										${specId }</td>
										<td width="10%"><input type="text" name="spcCode" id="spcCode_${major.mainSpecId}_${spec.specificationId}" value="${spec.specCode}" size="10" maxlength="20"/></td>
										<td width="10%"><input type="text" name="spcBarCode" id="spcBarCode_${major.mainSpecId}_${spec.specificationId}" value="${spec.barCode}" size="10" maxlength="10"/></td>
										<td width="8%"><input type="text" name="spcMaxCountPerOrder" id="spcMaxCountPerOrder_${major.mainSpecId}_${spec.specificationId}" value="${spec.maxCountPerOrder}" size="3" maxlength="3"/></td>
										<td width="8%"><input type="text" name="spcMinCountPerOrder" id="spcMinCountPerOrder_${major.mainSpecId}_${spec.specificationId}" value="${spec.minCountPerOrder}" size="3" maxlength="3"/></td>
										<td width="8%"><input type="text" name="spcSafeInventory" id="spcSafeInventory_${major.mainSpecId}_${spec.specificationId}" value="${spec.safeInventory}" size="3" maxlength="3"/></td>
										<td width="8%">${(specInvMap[spec.specificationId][0] - specInvMap[spec.specificationId][1] + specInvMap[spec.specificationId][2])<=0?'0':(specInvMap[spec.specificationId][0] - specInvMap[spec.specificationId][1] + specInvMap[spec.specificationId][2])}</td>
										<td width="8%">${specInvMap[spec.specificationId][1]}</td>
										<td width="8%">${specInvMap[spec.specificationId][2]}</td>
										<td width="8%">
											<a href="javascript:void(0);" onClick="return moveRowUp($(this),'moveSpec');" href="#">↑上移</a><br/>
											<a href="javascript:void(0);" onClick="return moveRowDown($(this),'moveSpec');" href="#">↓下移</a>	
										</td>
										<td width="5%">
											<c-rt:choose>
												<c-rt:when test="${'Y' eq specStatusParam}">
													<img src="${midContextPath}/images/dcdb.jpg"/>
												</c-rt:when>
												<c-rt:otherwise>
													<input name="secondDel" type="checkbox" id="secondDel_${major.mainSpecId}_${spec.specificationId}" value="${spec.specificationId}" ${spec.isDelete eq "Y" ? "checked='checked'" : "" }/>
												</c-rt:otherwise>
											</c-rt:choose>
										</td>
										<td width="10%"><a href="${midContextPath}/product/orderNotShipping.do?specificId=${spec.specificationId}&productId=${productId}" target="_blank">查询</a></td>
									</tr>
								</c-rt:forEach>
								<c-rt:if test="${not empty tmpSecondMap[major.mainSpecName]}">
									<tr class="moveSpec">
											<td width="10%">${tmpSecondMap[major.mainSpecName]}
												<input type="hidden" name="spcMajorName" value="${major.mainSpecName}"/>
												<input type="hidden" name="spcId" value=""/>
												<input type="hidden" name="spcName" value="${tmpSecondMap[major.mainSpecName]}" />
											</td>
											<td width="10%"><input type="text" name="spcCode" id="spcCode_spec_${mIndex.count}_${sIndex.count}" value="" size="10" maxlength="20"/></td>
											<td width="10%"><input type="text" name="spcBarCode" id="spcBarCode_spec_${mIndex.count}_${sIndex.count}" value="" size="10" maxlength="20"/></td>
											<td width="8%"><input type="text" name="spcMaxCountPerOrder" id="spcMaxCountPerOrder_spec_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
											<td width="8%"><input type="text" name="spcMinCountPerOrder" id="spcMinCountPerOrder_spec_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
											<td width="8%"><input type="text" name="spcSafeInventory" id="spcSafeInventory_spec_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
											<td width="8%">0</td>
											<td width="8%">0</td>
											<td width="8%">0</td>
											<td width="8%">
												<a href="javascript:void(0);" onClick="return moveRowUp($(this),'moveSpec');" href="#">↑上移</a><br/>
												<a href="javascript:void(0);" onClick="return moveRowDown($(this),'moveSpec');" href="#">↓下移</a>	
											</td>
											<td width="5%">
												<a href="javascript:void(0);" id="secondDel_spec_${mIndex.count}_${sIndex.count}">删除</a>
											</td>
											<td width="10%"></td>
									</tr>
								</c-rt:if>
							</table>
						</td>
					</tr>
				</c-rt:forEach>
				<c-rt:forEach items="${mainSpecName}" var="major" varStatus="mIndex">
					<tr class="moveMajor">
						<td width="80px">${major}
							<input type="hidden" name="majorName" value="${major}" />
							<input type="hidden" name="majorId" value=""/>
						</td>
						<td width="40px">
							<a href="javascript:void(0);" onClick="return moveRowUp($(this),'moveMajor');" href="#">↑上移</a><br/>
							<a href="javascript:void(0);" onClick="return moveRowDown($(this),'moveMajor');" href="#">↓下移</a>	
						</td>
						<td width="40px"><a href="javascript:void(0);" id="mainDel_major_${mIndex.count}">删除</a></td>
						<td colspan="13">
							<table class="tb-data" width="100%">
								<c-rt:forEach items="${addSpecSel}" var="spec" varStatus="sIndex">
									<tr class="moveSpec">
										<td width="10%">${spec}
											<input type="hidden" name="spcName" value="${spec}" />
											<input type="hidden" name="spcMajorName" value="${major}"/>
											<input type="hidden" name="spcId" value=""/>
										</td>
										<td width="10%"><input type="text" name="spcCode" id="spcCode_major_${mIndex.count}_${sIndex.count}" value="" size="10" maxlength="20"/></td>
										<td width="10%"><input type="text" name="spcBarCode" id="spcBarCode_major_${mIndex.count}_${sIndex.count}" value="" size="10" maxlength="20"/></td>
										<td width="8%"><input type="text" name="spcMaxCountPerOrder" id="spcMaxCountPerOrder_major_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
										<td width="8%"><input type="text" name="spcMinCountPerOrder" id="spcMinCountPerOrder_major_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
										<td width="8%"><input type="text" name="spcSafeInventory" id="spcSafeInventory_major_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
										<td width="8%">0</td>
										<td width="8%">0</td>
										<td width="8%">0</td>
										<td width="8%">
											<a href="javascript:void(0);" onClick="return moveRowUp($(this),'moveSpec');" href="#">↑上移</a><br/>
											<a href="javascript:void(0);" onClick="return moveRowDown($(this),'moveSpec');" href="#">↓下移</a>	
										</td>										
										<td width="5%">
											<a href="javascript:void(0);" id="secondDel_major_${mIndex.count}_${sIndex.count}">删除</a>
										</td>
										<td width="10%"></td>
									</tr>
								</c-rt:forEach>
							</table>
						</td>
					</tr>
				</c-rt:forEach>				
				</c-rt:if>
				<c-rt:if test="${empty addType and ( empty product.specifications or empty product.activateSpecMajors )}">
					<c-rt:forTokens items="${mainSpecName}" var="major" varStatus="mIndex" delims=",">
						<tr class="moveMajor">
							<td width="80px">${major}
								<input type="hidden" name="majorName" value="${major}" />
								<input type="hidden" name="majorId" value=""/>
							</td>
							<td width="40px">
								<a href="javascript:void(0);" onClick="return moveRowUp($(this),'moveMajor');" href="#">↑上移</a><br/>
								<a href="javascript:void(0);" onClick="return moveRowDown($(this),'moveMajor');" href="#">↓下移</a>	
							</td>
							<td width="40px"><a href="javascript:void(0);" id="mainDel_new_${mIndex.count}">删除</a></td>
							<td colspan="13">
								<table class="tb-data" width="100%">
									<c-rt:forTokens items="${secondSpecName}" var="spec" varStatus="sIndex" delims=",">
										<tr class="moveSpec">
											<td width="10%">${spec}
												<input type="hidden" name="spcName" value="${spec}" />
												<input type="hidden" name="spcId" value=""/>
												<input type="hidden" name="spcMajorName" value="${major}"/>
											</td>
											<td width="10%"><input type="text" name="spcCode" id="spcCode_new_${mIndex.count}_${sIndex.count}" value="" size="10" maxlength="20"/></td>
											<td width="10%"><input type="text" name="spcBarCode" id="spcBarCode_new_${mIndex.count}_${sIndex.count}" value="" size="10" maxlength="20"/></td>
											<td width="8%"><input type="text" name="spcMaxCountPerOrder" id="spcMaxCountPerOrder_new_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
											<td width="8%"><input type="text" name="spcMinCountPerOrder" id="spcMinCountPerOrder_new_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
											<td width="8%"><input type="text" name="spcSafeInventory" id="spcSafeInventory_new_${mIndex.count}_${sIndex.count}" value="" size="3" maxlength="3"/></td>
											<td width="8%">0</td>
											<td width="8%">0</td>
											<td width="8%">0</td>
											<td width="8%">
												<a href="javascript:void(0);" onClick="return moveRowUp($(this),'moveSpec');" href="#">↑上移</a><br/>
												<a href="javascript:void(0);" onClick="return moveRowDown($(this),'moveSpec');" href="#">↓下移</a>	
											</td>																					
											<td width="5%">
												<a href="javascript:void(0);" id="secondDel_new_${mIndex.count}_${sIndex.count}">删除</a>
											</td>
											<td width="10%"></td>
										</tr>
									</c-rt:forTokens>
								</table>
							</td>
						</tr>
					</c-rt:forTokens>
				</c-rt:if>
				<tr>
					<td colspan="16">
						<input type="hidden" name="mainSpecName" value="${mainSpecName}"/>
						<input type="hidden" name="secondSpecName" value="${secondSpecName}"/>
						<input type="hidden" name="productId" value="${product.productId}"/>
						<input type="hidden" name="specStatusParam" value="${specStatusParam}"/>
						<input type="hidden" id="saveFlag" name="saveFlag" value=""/>
						<input type="button" name="previous" id="previous" value="上一步"/>
						
						<input type="button" id="save" name="submit1" value="保存"/>
						<input type="button" id="next" name="submit2" value="保存到下一步"/>
						
					</td>
				</tr>				
		</tbody>
	</table>
</s:form>
</c-rt:if>
<div id="majorDialog" style="display:none;">
	<s:form action="addSpec.do" method="post" id="addMajorForm">
		输入新增主规格：<input type="text" name="mainSpecName" id="mainSpecName" size="16"/><br/>
		<span class="txt-gy">每个规格上限8个汉字</span><br/>
		请选择主规格包含的次规格：
		<span id="selSpecMsg">
			<c-rt:forTokens items="${product.secondSpecName}" var="spec" varStatus="sIndex" delims=",">
				<input type="checkbox" id="addSpec_${sIndex.count}" name="addSpecSel" value="${spec}"/>${spec}&nbsp;
			</c-rt:forTokens>
			<input type="checkbox" name="" value="" id="addSpecSelAll"/>全选&nbsp;<br/>
		</span>
		<br/>
		<input type="hidden" name="addType" value="major"/>
		<input type="button" id="addMajorBtn" value="提交"/>
		<input type="button" id="cancelMajorBtn" value="取消"/>
		<br/>
	</s:form>
</div>
<div id="specDialog" style="display:none;">
	<s:form action="addSpec.do" method="post" id="addSpecForm">
		<span class="txt-gy">你可以从已存在的次规格选择， 或是自行定义次规格</span><br/>
		<select name="secondSpecName1" id="secondSpecName1">
			<option value="">自定义</option>
			<c-rt:forTokens items="${product.secondSpecName}" var="spec" varStatus="sIndex" delims=",">
				<option value="${spec}">${spec}</option>
			</c-rt:forTokens>
		</select><br/>
		<div id="define">
			输入新增次规格：<input type="text" name="secondSpecName"  id="secondSpecName" size="16"/><br/>
			<span class="txt-gy">每个规格上限8个汉字</span><br/>
		</div>
		请选择该次规格从属的主规格,至少选择一个：<br/>
		<span id="selMajorMsg">
			<c-rt:forTokens items="${product.mainSpecName}" var="major" varStatus="mIndex" delims=",">
				<input type="checkbox" id="addMajor_${sIndex.count}" name="addMajorSel" value="${major}"/>${major}&nbsp;
			</c-rt:forTokens>
			<input type="checkbox" name="" value="" id="addMajorSelAll"/>全选&nbsp;<br/>
		</span>
		<br/>
		<input type="hidden" name="addType" value="spec"/>
		<input type="button" id="addSpecBtn" value="提交"/>
		<input type="button" id="cancelSpecBtn" value="取消"/>
		<br/>
	</s:form>
</div>